package com.passengerflowmanagementsystem.statistics.service.impl;

import java.util.List;
import com.passengerflowmanagementsystem.common.utils.DateUtils;
import com.passengerflowmanagementsystem.statistics.domain.*;
import com.passengerflowmanagementsystem.statistics.mapper.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.passengerflowmanagementsystem.statistics.service.IEmEquipmentService;

/**
 * 设备Service业务层处理
 * 
 * @author sheng
 * @date 2024-10-28
 */
@Service
public class EmEquipmentServiceImpl implements IEmEquipmentService 
{
    @Autowired
    private EmEquipmentMapper emEquipmentMapper;

    @Autowired
    private EmExhibitionShopMapper emExhibitionShopMapper;

    @Autowired
    private EmExhibitionHallMapper emExhibitionHallMapper;

    @Autowired
    private EmExhibitionCabinetMapper emExhibitionCabinetMapper;

    @Autowired
    private EmGetwayMapper emGetwayMapper;



    /**
     * 查询
     * 
     * @param equipmentId
     * @return
     */
    @Override
    public EmEquipment selectEmEquipmentByEquipmentId(Long equipmentId)
    {
        return emEquipmentMapper.selectEmEquipmentByEquipmentId(equipmentId);
    }

    /**
     * 查询
     * 
     * @param emEquipment
     * @return
     */
    @Override
    public List<EmEquipment> selectEmEquipmentList(EmEquipment emEquipment)
    {
        List<EmEquipment> equipmentList = emEquipmentMapper.selectEmEquipmentList(emEquipment);
        if (equipmentList.size() > 0){
            for (EmEquipment equipment : equipmentList){
                if (equipment.getShopId() != null) {
                    EmExhibitionShop shop = emExhibitionShopMapper.selectEmExhibitionShopByShopId(equipment.getShopId());
                    equipment.setShopName(shop.getShopName());
                }
                if (equipment.getHallId() != null){
                    EmExhibitionHall hall = emExhibitionHallMapper.selectEmExhibitionHallByHallId(equipment.getHallId());
                    equipment.setHallName(hall.getHallName());
                }
                if (equipment.getCabinetId() != null) {
                    EmExhibitionCabinet cabinet = emExhibitionCabinetMapper.selectEmExhibitionCabinetByCabinetId(equipment.getCabinetId());
                    equipment.setCabinetName(cabinet.getCabinetName());
                }
                if (equipment.getGetwayId() != null){
                    EmGetway getway = emGetwayMapper.selectEmGetwayByGetwayId(equipment.getGetwayId());
                    equipment.setGetwayName(getway.getGetwayName());
                }
            }
        }
        return equipmentList;
    }

    /**
     * 新增
     *
     * @param emEquipment
     * @return
     */
    @Override
    public int insertEmEquipment(EmEquipment emEquipment)
    {
        emEquipment.setCreateTime(DateUtils.getNowDate());
        return emEquipmentMapper.insertEmEquipment(emEquipment);
    }

    /**
     * 修改
     * 
     * @param emEquipment
     * @return
     */
    @Override
    public int updateEmEquipment(EmEquipment emEquipment)
    {
        emEquipment.setUpdateTime(DateUtils.getNowDate());
        return emEquipmentMapper.updateEmEquipment(emEquipment);
    }

    /**
     * 批量删除
     * 
     * @param equipmentIds
     * @return
     */
    @Override
    public int deleteEmEquipmentByEquipmentIds(Long[] equipmentIds)
    {
        return emEquipmentMapper.deleteEmEquipmentByEquipmentIds(equipmentIds);
    }

    /**
     * 删除
     * 
     * @param equipmentId
     * @return
     */
    @Override
    public int deleteEmEquipmentByEquipmentId(Long equipmentId)
    {
        return emEquipmentMapper.deleteEmEquipmentByEquipmentId(equipmentId);
    }
}
